package com.codemonkey.lq.extend.excelverification.result;

import com.codemonkey.lq.common.util.StringHelper;

/**
 * 校验结果
 * @author LQ
 *
 */
public class VerifyCellResult {

	private String name;
	private int index;
	private Object val;
	// 发生错误时的用户友好性提示信息
	private String prompt;
	// 发生错误时的详细信息, 程序员友好
	private String detail;
	private boolean isPass;

	public VerifyCellResult(boolean isPass, String name) {
		this.isPass = isPass;
		this.name = name;
	}

	public static VerifyCellResult noNeedVerify(String fieldName) {
		return new VerifyCellResultNoNeedVerify(fieldName);
	}

	public String getPrompt() {
		return StringHelper.isEmpty(prompt) ? "" : prompt;
	}

	public void setPrompt(String prompt) {
		this.prompt = prompt;
	}

	public boolean isPass() {
		return isPass;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public Object getVal() {
		return val;
	}

	public void setVal(Object val) {
		this.val = val;
	}

	public String getDetail() {
		return StringHelper.isEmpty(detail) ? "" : detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}

	// ---------------------------- Inner Class
	// 不需要校验
	static class VerifyCellResultNoNeedVerify extends VerifyCellResult {

		private VerifyCellResultNoNeedVerify(String name) {
			super(true, name);
			this.setDetail("");
			this.setPrompt("");
		}
	}
}
